<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="author" content="featon inc.">
        <link rel="stylesheet" href="/static/vendor/bootstrap/css/bootstrap.min.css">
        <link rel="stylesheet" href="/static/vendor/bootstrap/css/bootstrap-theme.min.css">
        <link rel="stylesheet" href="/static/vendor/font-awesome/css/font-awesome.min.css">
        <link rel="stylesheet" href="/static/vendor/jqPagination/css/jqpagination.css">

        <link href="/static/vendor/jquery-easyui/themes/default/tree.css" rel="stylesheet">
        <link href="/static/vendor/jquery-easyui/themes/icon.css" rel="stylesheet">
        <link href="/static/vendor/jquery-ui/themes/base/jquery.ui.all.css" rel="stylesheet">

        <link rel="stylesheet" href="/static/vendor/skin/ftskin.css">

        <title>信息列表</title>
    </head>

    <body>
        <div class="ft-subpage-wrapper container-fluid">

            <!-- 左导航开始	-->
            <div id="ftsidebar-subpage" style="overflow:auto;" class="ft-sidebar-box-subpage">
                <div class="leftTree-box">
                    <ul id="leftTree" class="easyui-tree" animate="true">

                    </ul>
                </div>
            </div>
            <!-- 左导航结束	-->

            <!-- 主窗口开始	-->
            <div id="ftmainBox" class="ft-mainBox">
                <div class="row">
                    <div class="container-fluid">
                        <div class="col-lg-12">
                            <div class="tools-box">
                                <button type="button" class="btn btn-info" onclick="openAddPage()"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 添加</button>
                                <button type="button" class="btn btn-warning" onclick="updateRecord(table,'menu_id','openUpdatePage()');"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> 修改</button>
                                <button type="button" class="btn btn-danger" onclick="deleteRecord(table,'menu_id','deleteObject()');"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 删除</button>
                                <button type="button" class="btn btn-info" onclick="publicSelectCheckbox(table,'menu_id','openSelectSinglMenuPage(\'选择菜单\',\'moveObject\')');"><span class="glyphicon glyphicon-export" aria-hidden="true"></span> 移动</button>
                                <button type="button" class="btn btn-success" onclick="sortRecord(table,'menu_id','sortObject()');"><span class="glyphicon glyphicon-floppy-saved" aria-hidden="true"></span> 保存排序</button>

                            </div>
                        </div>
                    </div>
                </div>


                <div class="row">
                    <div class="container-fluid">
                        <div class="col-lg-12" id="table">

                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="container-fluid">
                        <div id="turn">

                        </div>
                    </div>
                </div>

            </div>
            <!-- 主窗口结束	-->

        </div>
        <script src="/static/vendor/jquery/jquery-2.1.3.min.js"></script>
        <script src="/static/vendor/bootstrap/js/bootstrap.min.js"></script>

        <script src="/static/vendor/jquery-ui/minified/jquery-ui.min.js"></script>
        <script src="/static/vendor/jquery-easyui/jquery.easyui.min.js"></script>

        <link rel="stylesheet" href="/static/vendor/custom-scrollbar/jquery.mCustomScrollbar.min.css">
        <script src="/static/vendor/custom-scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>

        <script src="/static/vendor/jqPagination/js/jquery.jqpagination.min.js"></script>
        <script src="/static/vendor/skin/js/ft-ui.js"></script>
        <script src="/static/vendor/skin/js/tree-util.js"></script>
        <script src="/static/vendor/skin/js/table-common.js"></script>
        <script src="/static/vendor/skin/js/java.js"></script>
        <script src="/static/vendor/skin/js/jquery.c.js"></script>
        <script>
            var menu_id = 1;
            var tp = new TurnPage();
            var table = new Table();
            table.table_name = "table_list";
            var beanList = null;
            var jsonData;

            $(document).ready(function(){
                init_page();   //初始化页面内各BOX高度

                //table_input_init("dataTables-example-01"); //初始化input全选
                $("#ftsidebar-subpage").mCustomScrollbar({
                    theme:"minimal-dark"
                });

                initTable();
                showMenuTree();
                treeNodeSelected(1);
                loadListble();
            });

            $(window).resize(function(){
                init_page();
            });

            //初始化页面内各BOX高度
            function init_page()
            {
                var window_height = $(window).height();

                $("#ftmainBox").css("height",window_height-38);
                $("#ftsidebar-subpage").css("height",window_height-58);

            }

            function showMenuTree()
            {
                top.ajax.simple("/menu/getMenuTreeJsonStr/1",{},showMenuTreeHandl);
                //alert(top.ajax.syncl("/sys/cs/org/operate/getNewID",""))
            }

            function showMenuTreeHandl(obj)
            {
                json_data = obj;
                setLeftMenuTreeJsonData(json_data);
                initMenuTree();
                treeNodeSelected(menu_id);
            }

            function initMenuTree()
            {
                $('#leftTree').tree({
                    onClick:function(node){
                        changeMenuListTable(node.id);
                    }
                });

            }

            //点击树节点,修改菜单列表数据
            function changeMenuListTable(m_id){
                menu_id = m_id;
                loadListble();
            }

            function initTable(){

                var colsMap = new Map();
                var colsList = new List();

                colsList.add(setTitleClos("menu_id","ID","30px","","",""));
                colsList.add(setTitleClos("menu_name","菜单名称","200px","","",""));
                colsList.add(setTitleClos("action_space","操作","120px","","",""));
                colsList.add(setTitleClos("sort_col","排序","100px","","",""));
                colsList.add(setTitleClos("opt_name","权限名称","200px","","",""));
                colsList.add(setTitleClos("menu_url","链接地址","","","",""));


                table.setColsList(colsList);
                table.setAllColsList(colsList);
                table.enableSort=false;//禁用表头排序
                table.onSortChange = showList;
                table.show("table");//里面参数为外层div的id
            }

            function loadListble()
            {
                showMenuTree();
                showList();
                showTurnPage();
            }

            function showList(){

                beanList = top.ajax.syncl("/menu/getChildMenuList/"+menu_id,"");

                curr_bean = null;
                table.setBeanList(beanList,"td_list");//设置列表内容的样式
                table.show("table");

                tp.total = beanList.length;

                table.getCol("action_space").each(function(i){
                    if(i>0)
                    {
                        $(this).html('<a href="javascript:openUpdatePage('+beanList[i-1].menu_id+')">编辑</a>&nbsp;&nbsp;<a href="javascript:deleteSingleObject('+beanList[i-1].menu_id+')">删除</a>');
                    }
                });

                table.getCol("sort_col").each(function(i){
                    if(i>0)
                    {
                        $(this).html(getSortColStr());
                    }
                });
                table_input_init(table.table_name);
            }

            function showTurnPage(){

                tp.show("turn","simple");
                tp.onPageChange = showList;
            }

            function openAddPage()
            {
                modelWindow.openFrameWindow('维护菜单','/menu/go_menu_add?parentID='+menu_id,600,500);
            }

            function openUpdatePage(id)
            {
                var sel_id = '';
                if(id != '' && id != null)
                {
                    sel_id = id;
                }else
                    sel_id = table.getSelecteCheckboxValue("menu_id");
                modelWindow.openFrameWindow("维护菜单","/menu/go_menu_add?parentID="+menu_id+"&menu_id="+sel_id,600,500);
            }

            //打开菜单选择窗口
            function openSelectSinglMenuPage(title,handl_name)
            {
                modelWindow.openFrameWindow(title,"/menu/select_single_menu?handl_name="+handl_name,450,410);
            }

            function moveObject(parent_id)
            {
                if(parent_id != "" && parent_id != null)
                {
                    var selectIDS = table.getSelecteCheckboxValue("menu_id");
                    var om = new Map();
                    om.put("parent_id",parent_id+"");
                    om.put("menu_ids",selectIDS);
                    if(top.ajax.syncl("/menu/move",om.toJSON()))
                    {
                        modelWindow.alert("菜单"+top.CMSLang.Move_success);
                        loadListble()
                        showMenuTree();
                    }else
                    {
                        modelWindow.error("菜单"+CMSLang.Move_fail);
                        return;
                    }
                }
            }

            function deleteObject(id)
            {
                var sel_id = '';
                if(id != '' && id != null)
                {
                    sel_id = id;
                }else
                    sel_id = table.getSelecteCheckboxValue("menu_id");
                if(top.ajax.syncl("/menu/del",{"id":sel_id}))
                {
                    modelWindow.alert("菜单信息"+top.CMSLang.Delete_success);
                    deleteTreeNode(sel_id);
                    loadListble();
                }else
                {
                    modelWindow.error("菜单信息"+top.CMSLang.Delete_fail);
                }
            }

            function deleteSingleObject(id)
            {
                modelWindow.confirm("是否删除该条记录","deleteObject('"+id+"')")
            }

            function sortObject()
            {
                var selectIDS = table.getAllCheckboxValue("menu_id");
                if(top.ajax.syncl("/menu/sort",{"id":selectIDS}))
                {
                    modelWindow.alert(top.CMSLang.Sort_success);
                    showMenuTree();
                }else
                {
                    modelWindow.error(top.CMSLang.Sort_fail);
                }
            }
        </script>
    </body>
</html>